package com.qingrongby.shop.vo;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.domain.Page;

import java.util.List;

/**
 * @CLASSNAME Paging
 * @DESCRIPTION TODO
 * @AUTHOR hzp
 * @DATE 2020/6/25
 * @VERSION 1.0
 **/
@Setter
@Getter
@NoArgsConstructor
public class Paging<T> {
    private long total;
    private Integer count;
    private Integer page;
    private Integer totalPage;
    private List<T> items;

    public Paging(Page<T> pageT) {
        initPagingFiled(pageT);
        this.items = pageT.getContent();
    }

    void initPagingFiled(Page<T> pageT) {
        this.total = pageT.getTotalElements();
        this.count = pageT.getSize();
        this.page = pageT.getNumber();
        this.totalPage = pageT.getTotalPages();
    }

}
